package com.example.myapplication.test01

//入口函数
fun main() {
    println("Hello World!")
    val a = 10
    var b = 20
    println("a=$a")
    println("b=$b")
    b = 30
    println("b=$b")
    println("a+b=${a + b}")


    // 定义 repeatOperation 函数
    fun repeatOperation(times: Int) {
        for (i in 1..times) {
            println("迭代次数：$i")
        }
    }

    fun repeatOperation2(times: Int, block: () -> Unit) {
        for (i in 1..times) {
            block()
        }
    }
    repeatOperation(3)

    val input = "kotlin"
    val result = input.takeIf { it.length > 3 }?.uppercase() // "KOTLIN"
    println(result)

    println("你好,world!!")
//    repeatOperation(3) { iteration -> ... }  // 更简洁
}
